#ifndef accountmanager_utils_person_h
#define accountmanager_utils_person_h

#include <utils/utils_decl.h>

#include <utils/core/string.h>
#include <utils/core/set.h>

namespace AccountManagerUtils {
	
//! Information about a person
/*!
 *  A person is uniquely identified by its first, middle and last names.
 */
class _accountmanager_utils_decl Person {

public:
	Person();
	Person(const Person& rhs);
	Person(const String& first_name, const String& last_name);
	~Person();
	Person& operator=(const Person& rhs);

	bool operator==(const Person& rhs) const;
	bool operator!=(const Person& rhs) const;
	
	String& first_name();
	const String& first_name() const;
	String& middle_name();
	const String& middle_name() const;
	String& last_name();
	const String& last_name() const;
	String&  maiden_name();
	const String&  maiden_name() const;

	String full_name() const;

private:
	String first_name_;
	String middle_name_;
	String last_name_;
	String maiden_name_;
};

inline uint qHash(const Person& person) {
	return qHash(person.first_name()) ^ qHash(person.middle_name()) ^ qHash(person.last_name()) ^ qHash(person.maiden_name());
}

//===========================================================

//! Library of all persons available on the current session
class _accountmanager_utils_decl PersonLib {

public:
	static const Person* find_person(const String& first_name, const String& last_name);
	static const Set<Person>& persons();
	
	~PersonLib();

private:
	PersonLib();

	static PersonLib* instance();

private:
	Set<Person> persons_;
	static PersonLib* instance_;
};

} // namespace AccountManagerUtils

#endif
